﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.Odbc;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class public_html_NewSite_CMSV2_GamesAdd : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            TxtID.Text = Guid.NewGuid().ToString();
            ReviewerMySql SQL = new ReviewerMySql();
            OdbcDataReader MyReader = SQL.ExecuteReader("SELECT * FROM V2_GloGenres ORDER BY Navn");
            while (MyReader.Read())
            {
                ListGenre.Items.Add(new ListItem(MyReader[1].ToString(), MyReader[0].ToString()));
            }
        }
    }
    protected void BtmSaveGame_Click(object sender, EventArgs e)
    {
        ReviewerMySql SQL = new ReviewerMySql();

        for (int i = 0; i < ListFormat.Items.Count; i++)
        {
            if (ListFormat.Items[i].Selected)
            {
                string Dato = "";
                string Multi = "";
                int Format = int.Parse(ListFormat.Items[i].Value);

                if (Format == 1)
                {
                    Dato = DateXbox360.Text;
                    Multi = MultiXbox360.Text;
                }
                if (Format == 2)
                {
                    Dato = DatePC.Text;
                    Multi = MultiPC.Text;
                }
                if (Format == 3)
                {
                    Dato = DatePlaystation3.Text;
                    Multi = MultiPlaystation3.Text;
                }
                if (Format == 4)
                {
                    Dato = DateWii.Text;
                    Multi = MultiWii.Text;
                }

                SQL.ExecuteNonQuery("INSERT INTO V2_Spil (ID, SpilID, Titel, Udgiver, Udvikler, Genre, Multi, Format, ReleaseDato) VALUES (NULL , '" + TxtID.Text + "', '" + TxtTitel.Text + "', '" + TxtUdgiver.Text + "', '" + TxtUdvikler.Text + "', '" + ListGenre.SelectedValue + "', '" + Multi + "' , '" + Format + "', '" + Dato + "')");
            }
        }
        Response.Redirect("Message.aspx?Div=1&MSG= Spillet blev gemt!");
    }
}
